package EA;
import EA.testproblems.*; 

public class NumericalFramework extends Framework
{
  /** Number of dimensions in objective problem. */
  public int dimensions;
  /** Intervals for the objective problem. */
  public Interval[] intervals;

  /** Create a new NumericalFramework. This used when the framework is 
      just used to access implementation dependent variables.
  */
  public NumericalFramework()
    {
      super();
    }

  /** Create a new NumericalFramework. */
  public NumericalFramework(Fitness ffunction)
    {
    super(ffunction);
    }

  public NumericalFramework(int thedimensions, Fitness ffunction)
    {
      super(ffunction);
      dimensions = thedimensions;
    }

  public NumericalFramework(int thedimensions, Interval[] theintervals, Fitness ffunction)
    {
      super(ffunction);
      dimensions = thedimensions;
      intervals = theintervals;
    }

  public NumericalFramework(int thedimensions, Interval[] theintervals)
    {
      super();
      dimensions = thedimensions;
      intervals = theintervals;
    }

  public NumericalFramework(NumericalProblem numproblem)
    {
      super(numproblem.objectivefunction);
      dimensions = numproblem.dimensions;
      intervals = numproblem.intervals;
    }

  public void setIntervals(Interval[] theintervals)
    {
      intervals = theintervals;
    }

  /** Set the framework to optimize <tt>numproblem</tt>. */
  public void setProblem(NumericalProblem numproblem)
    {
      fitnessfunction = numproblem.objectivefunction;
      dimensions = numproblem.dimensions;
      intervals = numproblem.intervals;
      ismaximization = numproblem.ismaximization;
    }

  /** Get the fitness of a point. This method calls fitnessfunction.calcFitness()
      @param realpos The point to calculate fitness for.
      @return The fitness of <tt>realpos</tt>.
  */
  public double getFitness(double[] realpos)
    {
      return ((NumericalFitness)fitnessfunction).calcFitness(realpos);
    }

}
